/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package modelo;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Andre
 */
@Entity
@Table(name = "espacamento")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Espacamento.findAll", query = "SELECT e FROM Espacamento e"),
    @NamedQuery(name = "Espacamento.findByIdEspacamento", query = "SELECT e FROM Espacamento e WHERE e.idEspacamento = :idEspacamento"),
    @NamedQuery(name = "Espacamento.findByTamanho", query = "SELECT e FROM Espacamento e WHERE e.tamanho = :tamanho")})
public class Espacamento implements Serializable {
    
    private static final long serialVersionUID = 1L;
    
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "idEspacamento", nullable = false)
    private Integer idEspacamento;
    
    @Basic(optional = false)
    @NotNull
    @Column(name = "tamanho", nullable = false)
    private double tamanho;
    
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "espacamento")
    private List<Roda> rodaList;

    public Espacamento() {
    }

    public Espacamento(Integer idEspacamento) {
        this.idEspacamento = idEspacamento;
    }

    public Espacamento(Integer idEspacamento, double tamanho) {
        this.idEspacamento = idEspacamento;
        this.tamanho = tamanho;
    }

    public Integer getIdEspacamento() {
        return idEspacamento;
    }

    public void setIdEspacamento(Integer idEspacamento) {
        this.idEspacamento = idEspacamento;
    }

    public double getTamanho() {
        return tamanho;
    }

    public void setTamanho(double tamanho) {
        this.tamanho = tamanho;
    }

    @XmlTransient
    public List<Roda> getRodaList() {
        return rodaList;
    }

    public void setRodaList(List<Roda> rodaList) {
        this.rodaList = rodaList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idEspacamento != null ? idEspacamento.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Espacamento)) {
            return false;
        }
        Espacamento other = (Espacamento) object;
        if ((this.idEspacamento == null && other.idEspacamento != null) || (this.idEspacamento != null && !this.idEspacamento.equals(other.idEspacamento))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "modelo.Espacamento[ idEspacamento=" + idEspacamento + " ]";
    }
    
}
